# coding: utf-8

import sys
sys.path.append('../3_data_structure')
from stack import Stack


def convert_decimal_to_base(input_number, base):
    stack = Stack()

    while input_number:
        mod = input_number % base
        input_number //= base

        stack.push(mod)

    result = ''
    digits = '0123456789abcdef'

    while not stack.is_empty():
        result += digits[stack.pop()]

    return result


print(convert_decimal_to_base(5, 2))
print(convert_decimal_to_base(127, 16))
print(convert_decimal_to_base(1024, 16))
print(convert_decimal_to_base(25, 8))
